/**
 * http://usejsdoc.org/
 */
var req,res,
	fs = require('fs'),
	url = require('url'),
	querystring = require('querystring');

/**创建初始变量函数*/
exports.init = function(response,request){
	res = response;
	req = request;
};


/**
 * 获取GET参数方法
 */
exports.GET = function(key){
	var paramStr = url.parse(req.url).query,
		param = querystring.parse(paramStr);
	return param[key] ? param[key]:'';
};


/**
 * 获取POST参数方法
 */
exports.POST = function(key,callback){
	var postData = '';
	//设置接收数据编码格式为UTF-8
	req.setEncoding('utf-8');
	//接收数据块并将其赋值给postData
	req.addListener('data',function(postDataChunk){
		postData += postDataChunk;
	});
	//接收数据完毕执行回调
	req.addListener('end',function(){
		var param = querystring.parse(postData);
		var value = param[key]?param[key]:'';
		callback(value);
	});
};